﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CastleDemo1._Default" EnableEventValidation="false" EnableViewState="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script type="text/javascript">
        function checkNull() {
            if ($('#txtTitle').val() == "" || $('#txtContent').val() == "") {
                alert('标题或内容不能为空');
                return false;
            }
            else {
                return true;
            }
        }
        function checkExist() {
            var postTitle = $('#txtTitle').val();
            $.post('CheckExistHandler.ashx', { 'posttitle': postTitle }, function (result) {
                $('#info').text(result);
            }, '_default');
        }
        $(document).ready(function () {
           // $('#btnAdd').bind('click', checkNull);
            $('#txtTitle').bind('blur',checkExist);
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table border="1" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <td>标题</td>
                    <td>内容</td>
                    <td>作者</td>
                    <td>日期</td>
                    <td colspan="3">编辑</td>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater runat="server" ID="repPost">
                <ItemTemplate>
                <tr>
                    <td><%#Eval("Title") %></td>
                    <td><%#Eval("ShortContent")%></td>
                    <td><%#Eval("Author") %></td>
                    <td><%#Eval("PublishDate") %></td>
                    <td><a href='EditPost.aspx?Action=Edit&PostId=<%#Eval("PostId")%>'>编辑</a></td>
                    <td><a href='Default.aspx?Action=Delete&PostId=<%#Eval("PostId")%>' onclick="return confirm('确认删除吗?')">删除</a></td>
                    <td><a href='CommentList.aspx?Action=Query&PostId=<%#Eval("PostId")%>'>查看回复</a></td>
                </tr>
                </ItemTemplate>
            </asp:Repeater> 
            </tbody>           
        </table>
        标题:<asp:TextBox runat="server" ID="txtTitle"/> <span id="info"></span>  <br />
         内容:<asp:TextBox runat="server"  ID="txtContent"/> <br />
        <asp:Button ID="btnAdd" runat="server" Text="添加" onclick="btnAdd_Click" />     
    </div>
    </form>
</body>
</html>
